package edu.drexel.jrexel2d.physics;

public class VelocityVector{
	
	private double x = 0.0;
	private double y = 0.0;
	
	private double xAcceleration = 0.0;
	private double yAcceleration = 0.0;
	
	public static VelocityVector ZERO_VEL_VECTOR = new VelocityVector(0.0, 0.0);
	
	public VelocityVector(){
		//Default Constructor
	}
	
	public VelocityVector(double inX, double inY){
		
		x = inX;
		y = inY;
		
	}
	
	public double getXVelocity(){
		return x;	
	}
	
    public double getYVelocity(){
    	return y;	
	}
    
   public double getXAcceleration(){

		return xAcceleration;	
	}
	
    public double getYAcceleration(){
    	return yAcceleration;	
	}
    
    public void setXAcceleration(double xAccel){
		xAcceleration = xAccel;	
	}
	
    public void setYAcceleration(double yAccel){
    	yAcceleration = yAccel;	
	}
	
    public void setXVelocity(double newXVelocity){
    	x = newXVelocity;	
    }
    
    public void setYVelocity(double newYVelocity){	
    	y = newYVelocity;
    }
    
    public boolean isEqual(VelocityVector inVector){
    	
    	boolean retValue = false;
    	
    	if((this.getXVelocity() == inVector.getXVelocity()) &&
    		(this.getYVelocity() == inVector.getYVelocity())){
    		
    		retValue = true;
    		
    	}
    	
    	return retValue;
    }
    
    public void update(double inDelta){
    	
    	//convert milliseconds to seconds
    	double inDeltaSeconds = inDelta / 1000;
    	
    	x = Math.CalculateVelocityComponent(x, inDeltaSeconds, xAcceleration);
    	y = Math.CalculateVelocityComponent(y, inDeltaSeconds, yAcceleration);
    	
    }
    
public void update(double inDelta, double frictionalConstant){
    	
    	//convert milliseconds to seconds
    	double inDeltaSeconds = inDelta / 1000;
    	
    	xAcceleration = xAcceleration + frictionalConstant;
    	
    	x = Math.CalculateVelocityComponent(x, inDeltaSeconds, xAcceleration);
    	y = Math.CalculateVelocityComponent(y, inDeltaSeconds, yAcceleration);
    	
    }
    
    public double getMagnitude(){
    	
    	return java.lang.Math.sqrt((java.lang.Math.pow(x, 2) + java.lang.Math.pow(y, 2)));
    	
    }
    
}